www.gusucode.com > VC++ 新手写的简单客房管理系统源码程序 > VC++ 新手写的简单客房管理系统源码程序/code/tot/FangDialog.cpp

    // FangDialog.cpp : implementation file
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "tot.h"
#include "FangDialog.h"
#include "FangSet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFangDialog dialog
//#include "FangSet.h"


CFangDialog::CFangDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CFangDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFangDialog)
	m_cpeople = 0;
	m_cprice = 0;
	m_croom = 0;
	m_cstatue = _T("");
	m_edit1 = _T("");
	//}}AFX_DATA_INIT


//if(!m_data.Open(NULL,FALSE,FALSE,"ODBC;DSN=Room"))
//{AfxMessageBox("不能打开数据库");}




}


void CFangDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFangDialog)
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Text(pDX, IDC_CPEOPLE, m_cpeople);
	DDX_Text(pDX, IDC_CPRICE, m_cprice);
	DDX_Text(pDX, IDC_CROOM, m_croom);
	DDX_Text(pDX, IDC_CSTATUE, m_cstatue);
	DDX_Text(pDX, IDC_EDIT1, m_edit1);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFangDialog, CDialog)
	//{{AFX_MSG_MAP(CFangDialog)
	ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFangDialog message handlers

/*void CFangDialog::OnFangstate() 
{
	// TODO: Add your control notification handler code here
	
}*/

BOOL CFangDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString mmsg;
	mmsg+="请双击一个房间号!!";
    

	m_list.AddString("101");
	m_list.AddString("102");
	m_list.AddString("103");
	m_list.AddString("104");
	m_list.AddString("105");
	m_list.AddString("106");
	m_list.AddString("201");

	m_list.AddString("202");
	m_list.AddString("203");
	m_list.AddString("204");
	m_list.AddString("205");
	m_list.AddString("206");
	m_list.AddString("301");
	m_list.AddString("302");
	m_list.AddString("303");
	m_list.AddString("304");
	m_list.AddString("305");
	m_list.AddString("306");
	m_edit1=mmsg;
UpdateData(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CFangDialog::OnDblclkList1() 
{
	// TODO: Add your control notification handler code here
//	UpdateData(true);

	CString str;
//

CDatabase m_data;
	if(!m_data.Open(_T("Room")))
		AfxMessageBox("数据库打开出错");
//
   m_fset.Open();
 m_fset.MoveFirst();
m_list.GetText(m_list.GetCurSel(),str);
m_croom=(long)atof((LPCTSTR)str);
//UpdateData(false);
//
//AfxMessageBox("0000000000000");
//

	while(!m_fset.IsEOF())
	     {  if(m_fset.m_roomID==m_croom)
		   {//AfxMessageBox("11111111111");
	         m_cstatue=m_fset.m_state;
  	       
			       m_cprice=m_fset.m_daycost;
				   m_cpeople=m_fset.m_max;
				   break;
			     }
	         
		    
	         else m_fset.MoveNext();
	     }
UpdateData(false);
m_fset.Close();
	m_data.Close();
}